<extend name="Public/base" />

<block name="body">
    <!-- 标题栏 -->
    <div class="main-title">
        <h2>{$meta_title}</h2>
    </div>
    <div class="cf">
        <div class="fl">
            <a class="btn" href="{:U('add')}">新 增</a>
            <button class="btn ajax-post confirm" url="{:U('del')}" target-form="ids">删 除</button>
        </div>
    </div>
    <!-- 数据列表 -->
    <div class="data-table table-striped">
        <table>
            <thead>
            <tr>
                <th class="row-selected row-selected"><input class="check-all" type="checkbox"/></th>
                <th class="" width="60">排序</th>
                <th class="" width="60">标题</th>
                <th class="" width="100">链接</th>
                <th class="" width="60">图片</th>
               
                <th class="" width="150">描述</th>
                <th class="">类型</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody class="setfield">
                <notempty name="list">
                    <volist name="list" id="vo">
                        <tr>
                            <form action="{:U('setfield')}" method="post">
                                <input type="hidden" name="id" value="{$vo.id}" >
                                <td><input class="ids" type="checkbox" name="ids[]" value="{$vo.id}" /></td>
                                <td><input type="text" name="sort" class="text input-mini" value="{$vo.sort|default='0'}"></td>
                                <td><input type="text" name="title" class="text input-small" value="{$vo.title|default=''}"> </td>
                                <td>{$vo.url} </td>
                                <td>{$vo.cover_id}</td>
                                
                                <td>{$vo.description}</td>
                                <td>{$vo['type'] == 1 ? '友情链接' : '友情链接' }</td>
                                <td>
                                    <a href="{:U('edit',array('id'=>$vo['id']))}" class="authorize">编辑</a>
                                    <a title="{$vo.status|show_status_op}" href="{:U('setStatus?ids='.$vo['id'].'&status='.abs(1-$vo['status']))}" class="ajax-get">{$vo.status|show_status_op}</a>
                                    <a href="{:U('del',array('id'=>$vo['id']))}" class="confirm ajax-get">删除</a>
                                </td>
                            </form>
                        </tr>
                    </volist>
                <else/>
                    <td colspan="3" class="text-center"> aOh! 暂时还没有内容! </td>
                </notempty>
            </tbody>
        </table>
    </div>
    <div class="page">
        {$_page}
    </div>
</block>

<block name="script">
    <script type="text/javascript">
        (function($){
            $(".setfield")
                .on("submit", "form", function(){
                    var self = $(this);
                    $.post(
                        self.attr("action"),
                        self.serialize(),
                        function(data){
                            /* 提示信息 */
                            var name = data.status ? "success" : "error", msg;
                            msg = self.find(".msg").addClass(name).text(data.info)
                                      .css("display", "inline-block");
                            setTimeout(function(){
                                msg.fadeOut(function(){
                                    msg.text("").removeClass(name);
                                });
                            }, 1000);
                        },
                        "json"
                    );
                    return false;
                })
                .on("change","input",function(){
                    $(this).parent().parent().find("form").submit();
                });
        })(jQuery);
        //导航高亮
        highlight_subnav("{:U('index')}");
    </script>
</block>
